package com.maxie.mq.demo.adapter;


import com.maxie.mq.demo.sdkmq.RabbitMQSerive;
import com.maxie.mq.demo.sdkmq.RocketMQSerive;
import com.maxie.mq.demo.sdkmq.vo.RabbitVO;
import com.maxie.mq.demo.sdkmq.vo.RocketVO;
import com.maxie.mq.demo.service.MesssgaeCosummer;
import com.maxie.mq.demo.vo.MessgaeVO;

public class MeaasgeAdapter {  // 应该是 MessageAdapter

    private MesssgaeCosummer consumer;

    public MeaasgeAdapter(MesssgaeCosummer consumer) {
        this.consumer = consumer;
    }

    /**
     * 适配 RabbitMQ 消息
     */
    public void consumeRabbitMQ(RabbitMQSerive rabbitService) {
        RabbitVO rabbitVO = rabbitService.send();

        // 适配转换
        MessgaeVO messageVO = new MessgaeVO(rabbitVO.getId(), rabbitVO.getMessage());
        consumer.recive(messageVO);
    }

    /**
     * 适配 RocketMQ 消息
     */
    public void consumeRocketMQ(RocketMQSerive rocketService) {
        RocketVO rocketVO = rocketService.send();

        // 适配转换
        MessgaeVO messageVO = new MessgaeVO(rocketVO.getId(), rocketVO.getdesc());
        consumer.recive(messageVO);
    }
}